package com.tutou.ikuser.pojo.po;

import lombok.Data;
import lombok.NoArgsConstructor;
//import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

@Data
@NoArgsConstructor
public class SecurityUser implements UserDetails {
    private User user;

    public SecurityUser(User user) {
        this.user = user;
    }

    // 这里返回null，表示未实现获取权限的逻辑
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return user.getPassword();
    }

    @Override
    public String getUsername() {
        return user.getUserName();
    }

    // 这里直接返回true，表示账户不过期
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    // 这里直接返回true，表示账户未被锁定
    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    // 这里直接返回true，表示凭证不过期
    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    // 这里直接返回true，表示用户启用状态为true
    @Override
    public boolean isEnabled() {
        return true;
    }
}
